﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BasicComponents.com
{
    /// <summary>
    /// LabelTextBox.xaml 的交互逻辑
    /// </summary>
    public partial class LabelTextBox : UserControl
    {
        public LabelTextBox()
        {
            InitializeComponent();
        }
        //1、注册标题内容
        public String Title
        {
            get { return (String)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(String), typeof(LabelTextBox), new PropertyMetadata("", (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox;
                sender.Label_title.Content = e.NewValue.ToString();
            }));
        //2、注册值内容
        public String Text
        {
            get { return this.TBox_text.Text; }
            set { this.TBox_text.Text = value; }
        }
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(String), typeof(LabelTextBox), new PropertyMetadata("", (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox;
                sender.Text = e.NewValue.ToString();
            }));
        
        //3、注册readOnly
        public Boolean IsReadOnly
        {
            get { return (Boolean)GetValue(IsReadOnlyProperty); }
            set { SetValue(IsReadOnlyProperty, value); }
        }
        public static readonly DependencyProperty IsReadOnlyProperty =
            DependencyProperty.Register("IsReadOnly", typeof(Boolean), typeof(LabelTextBox), new PropertyMetadata(false, (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox;
                sender.TBox_text.IsReadOnly = (Boolean)e.NewValue;
                if (((Boolean)e.NewValue))
                {
                    sender.TBox_text.Background = Brushes.Lavender;
                }
                else
                {
                    sender.TBox_text.Background = Brushes.White;
                }
            }));
         
        //4、注册text宽度
         public new Double  Width
        {
            get { return (Double)GetValue(WidthProperty); }
            set { SetValue(WidthProperty, value); }
        }
        public static readonly new DependencyProperty WidthProperty =
            DependencyProperty.Register("Width", typeof(Double), typeof(LabelTextBox), new PropertyMetadata(120.00, (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox;
                sender.TBox_text.Width = (Double)e.NewValue;
            }));
        //5、注册text高度
        public new Double Height
        {
            get { return (Double)GetValue(HeightProperty); }
            set { SetValue(HeightProperty, value); }
        }
        public static readonly new DependencyProperty HeightProperty =
            DependencyProperty.Register("Height", typeof(Double), typeof(LabelTextBox), new PropertyMetadata(23.00, (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox;
                sender.TBox_text.Height = (Double)e.NewValue;
            })); 
        
        //7、注册Label字体大小
        public  int FontSize_Title
        {
            get { return (int)GetValue(FontSize_TitleProperty); }
            set { SetValue(FontSize_TitleProperty, value); }
        }
        public static readonly  DependencyProperty FontSize_TitleProperty =
            DependencyProperty.Register("FontSize_Title", typeof(int), typeof(LabelTextBox), new PropertyMetadata(12, (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox; 
                sender.Label_title.FontSize = (int)e.NewValue;
            }));
        //8、注册Label字体FontWeight
        public  FontWeight FontWeight_Title
        {
            get { return (FontWeight)GetValue(FontWeight_TitleProperty); }
            set { SetValue(FontWeight_TitleProperty, value); }
        }
        public static readonly  DependencyProperty FontWeight_TitleProperty =
            DependencyProperty.Register("FontWeight_Title", typeof(FontWeight), typeof(LabelTextBox), new PropertyMetadata(FontWeights.Normal, (s, e) =>
            {
                LabelTextBox sender = s as LabelTextBox; 
                sender.Label_title.FontWeight = (FontWeight)e.NewValue;
            }));
        
    }
}
